package com.party.course.controller;


import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;

import com.party.common.annotation.Log;
import com.party.common.core.controller.BaseController;
import com.party.common.core.domain.AjaxResult;
import com.party.common.enums.BusinessType;
import com.party.common.utils.SecurityUtils;
import com.party.common.utils.poi.ExcelUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.party.course.domain.AmountInfo;
import com.party.course.service.IAmountInfoService;
import com.party.common.core.page.TableDataInfo;

/**
 * 金额明细Controller
 *
 * @author ruoyi
 * @date 2025-05-29
 */
@RestController
@RequestMapping("/course/AmountInfo")
public class AmountInfoController extends BaseController {
    @Autowired
    private IAmountInfoService amountInfoService;

    /**
     * 查询金额明细列表
     */
//@RequiresPermissions("course:AmountInfo:list")
    @GetMapping("/list")
    public TableDataInfo list(AmountInfo amountInfo) {
        startPage();
        List<AmountInfo> list = amountInfoService.findList(amountInfo);
        return getDataTable(list);
    }

    @GetMapping("/otherList")
    public AjaxResult findListOther(AmountInfo amountInfo) {
        HashMap<String, Object> map = amountInfoService.findListOther(amountInfo);
        return AjaxResult.success(map);
    }

    @GetMapping("/findListApp")
    public AjaxResult findListApp(String validTime,String wageType) {
        HashMap<String, Object> listApp = amountInfoService.findListApp(validTime, wageType);
        return AjaxResult.success(listApp);
    }

    @GetMapping("/findCashAmount")
    public AjaxResult findListApp() {
        return AjaxResult.success(amountInfoService.findCashAmount(SecurityUtils.getUserIdStr()));
    }

//    /**
//     * 导出金额明细列表
//     */
//    //@RequiresPermissions("course:AmountInfo:export")
//    @Log(title = "金额明细", businessType = BusinessType.EXPORT)
//    @PostMapping("/export")
//    public void export(HttpServletResponse response, AmountInfo amountInfo) {
//        List<AmountInfo> list = amountInfoService.findList(amountInfo);
//        ExcelUtil<AmountInfo> util = new ExcelUtil<AmountInfo>(AmountInfo.class);
//        util.exportExcel(response, list, "金额明细数据");
//    }

    /**
     * 获取金额明细详细信息
     */
    //@RequiresPermissions("course:AmountInfo:query")
    @GetMapping(value = "/view/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id) {
        return AjaxResult.success(amountInfoService.view(id));
    }

    /**
     * 新增金额明细
     */
    //@RequiresPermissions("course:AmountInfo:add")
    @Log(title = "金额明细", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    public AjaxResult add(@RequestBody AmountInfo amountInfo) {
        return toAjax(amountInfoService.add(amountInfo));
    }

    /**
     * 修改金额明细
     */
    //@RequiresPermissions("course:AmountInfo:edit")
    @Log(title = "金额明细", businessType = BusinessType.UPDATE)
    @PutMapping("/update")
    public AjaxResult edit(@RequestBody AmountInfo amountInfo) {
        return toAjax(amountInfoService.updateEntity(amountInfo));
    }

    /**
     * 删除金额明细
     */
    //@RequiresPermissions("course:AmountInfo:remove")
    @Log(title = "金额明细", businessType = BusinessType.DELETE)
    @DeleteMapping("/delete/{ids}")
    public AjaxResult remove(@PathVariable String[] ids) {
        return toAjax(amountInfoService.deleteIds(Arrays.asList(ids)));
    }
}
